#ifndef COLLECTION_H_
#define COLLECTION_H_

template <class Item>
class Collection
{
public:
	virtual ~Collection() {}

protected:
	Collection() {}

public:
	virtual int count() const = 0;
	virtual Item* get(int) const = 0;
};

template <class Item>
class List : public Collection<Item>
{
public:
	List(int count = 1);
	virtual ~List();

public:
	virtual int count() const;
	virtual Item* get(int) const;

private:
	int m_count;
	Item* m_list;
};

template <class Item>
List<Item>::List(int count)
{
	m_count = count;

	m_list = new Item[m_count];
}

template <class Item>
List<Item>::~List()
{
	if (m_list)
	{
		delete[] m_list, m_list = NULL;
	}
}

template <class Item>
int List<Item>::count() const
{
	return m_count;
}

template <class Item>
Item* List<Item>::get(int index) const
{
	if (index < 0 || index >= m_count)
	{
		throw -1;
	} 
	else
	{
		return &(m_list[index]);
	}
}

#endif // COLLECTION_H_

